import QueryChooser from 'components/Markdown/QueryChooser'

export const meta = {
  title: 'Setting up Prisma',
  gettingStartedTitle: 'Free & hosted demo server',
  position: 1,
  gettingStartedOrder: 1,
  nextText: 'Great work! 👏  Move on to learn how you can extend your data model and make changes to your Prisma API.'
}

## Goals

On this page, you will learn how to:

- Install the Prisma CLI
- Create a Prisma service configuration
- Deploy a Prisma service to a Demo server in Prisma Cloud
- Explore the Prisma API in a GraphQL Playground

## Install the Prisma CLI

The [Prisma CLI](https://www.npmjs.com/package/prisma) is used to deploy and manage Prisma services. You can install it using NPM:

```bash copy
npm install -g prisma
```

## Create a Prisma service configuration

To bootstrap the configuration files for your first Prisma service, create a new directory and initalize it using the `prisma init` command:

```bash copy
mkdir hello-world
cd hello-world
prisma init
```

After running `prisma init`, the Prisma CLI prompts you to select _how_ you want to deploy your Prisma service:

1. Select **Demo server** from the list.
1. When your browser opens, register with [Prisma Cloud](https://www.prisma.io/cloud/). This is needed because that's where the Demo server is hosted.
1. Go back to your terminal.
1. Choose the suggested values for all following questions by just hitting **Enter** until the interactive prompt terminates.

## Deploy the Prisma service

The `prisma init` command created the _minimal_ service configuration needed to deploy a Prisma service: `prisma.yml` and `datamodel.graphql`. This service configuration now needs to be _deployed_ so you can use the Prisma API of your service:

```bash copy
prisma deploy
```

## Explore the Prisma API in a Playground

The Prisma API of your service exposes CRUD operations for the `User` type defined in `datamodel.graphql`. Here are a few sample queries and mutations you can send to explore the API.

<QueryChooser titles={["Create new user", "Query all users", "Update a user's name", "Delete user"]}>

```graphql lineNumbers,copy
mutation {
  createUser(data: {
    name: "Alice"
  }) {
    id
  }
}
```

```graphql lineNumbers,copy
query {
  users {
    id
    name
  }
}
```

```graphql lineNumbers,copy
mutation {
  updateUser(
    where: { id: "__USER_ID__" },
    data: { name: "Sarah" }
  ) {
    id
    name
  }
}
```

```graphql lineNumbers,copy
mutation {
  deleteUser(where: {
    id: "__USER_ID__"
  }) {
    id
    name
  }
}
```

</QueryChooser>
